package cn.liulin.spring_boot_study.pojo;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * cn.liulin.spring_boot_study.pojo$
 *
 * @author ll
 * @date 2021-10-22 11:46:53
 **/
//@Component
public class BussinessPerson implements Person{

//    @Autowired
//    @Qualifier("cat")
    private Animal animal;
    // private Animal cat;
    // autowired可以根据type或着属性名来确定最终的注入类
    // autowired可以用于setAnimal上

    public BussinessPerson(Animal animal) {
        this.animal = animal;
    }

    @Override
    public void service() {
        animal.use();
    }

    @Override
    @Autowired
    public void setAnimal(Animal animal) {
        System.out.println("延迟依赖注入");
        this.animal = animal;
    }
}
